import { Component } from 'react'
import { Provider } from 'mobx-react'
// import Taro from '@tarojs/taro';
import { Text, View } from '@tarojs/components';
import { getAppIDInfo } from './config/template';
import stores from './models'
import { isDev, miniProgramVersion, miniProgramVersionNum } from './utils'
import { StoresContext } from './hooks'

import './app.less'

__non_webpack_require__.async('./pages/configDevice/sentry-miniapp.wx.min').then((Sentry) => {
  Sentry.init({
    dsn: "https://50d1621ef1b04c5a990ed56ac9ab903f@appmonitor.gizwits.com/83",
    enabled: !isDev(),
  });


  const appInfo = getAppIDInfo();
  Sentry.configureScope((scope) => {
    scope.setTag("appId", appInfo.appId);
    scope.setTag("miniProgramVersion", miniProgramVersion);
    if (miniProgramVersionNum && miniProgramVersionNum.length > 0) {
      scope.setTag("miniProgramVersionNum", miniProgramVersion);
    }
  });
});


class App extends Component {

  componentDidMount() {
    // Taro.onError((e) => {
    //   console.log("Taro.onError", e);
    // })
    // Taro.onUnhandledRejection((e) => {
    //   console.log("onUnhandledRejection", e);
    // })
  }

  componentDidShow() { }

  componentDidHide() { }

  componentDidCatchError(e) {
    // console.log("componentDidCatchError", e);
  }

  render() {
    return (
      <Provider {...stores}>
        <StoresContext.Provider value={stores}>
          {this.props.children}
        </StoresContext.Provider>
      </Provider>
    )
  }
}

export default App
